package com.yugao.fintech.antelope.infra.weixin.mp.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yugao.fintech.antelope.infra.weixin.mp.utils.MpUtils;
import com.yugao.fintech.antelope.base.model.BasePlusPO;
import com.yugao.fintech.antelope.base.model.constants.ValidationCons;
import com.yugao.fintech.antelope.base.tenant.core.DataIsolation;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.common.api.WxConsts;

import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 公众号菜单表
 *

 */
@Getter
@Setter
@TableName(value = "wx_mp_menu", autoResultMap = true)
@DataIsolation(filterTenant = true, tableName = "wx_mp_menu")
public class MpMenu extends BasePlusPO {
	/**
	 * 主键
	 */
    @TableId
	private Long id;

	/**
	 * 微信公众号 appid
	 */
	private String mpAppId;
	
	/**
	 * 菜单名称
	 */
	private String name;
	
	/**
	 * 菜单标识
	 */
	@NotEmpty(message = ValidationCons.NOT_EMPTY)
	private String menuKey;
	
	/**
	 * 父ID
	 */
	private Long parentId;
	
	/**
	 * 按钮类型
	 */
	@NotEmpty(message = ValidationCons.NOT_EMPTY)
	private String type;
	
	/**
	 * 网页链接
	 */
	@NotEmpty(message = "网页链接不能为空", groups = {MpUtils.ViewButtonGroup.class, MpUtils.MiniProgramButtonGroup.class})
	private String url;
	
	/**
	 * 小程序appid
	 */
	@NotEmpty(message = "小程序的 appId 不能为空", groups = MpUtils.MiniProgramButtonGroup.class)
	private String miniProgramAppId;
	
	/**
	 * 小程序页面路径
	 */
	@NotEmpty(message = "小程序的页面路径不能为空", groups = MpUtils.MiniProgramButtonGroup.class)
	private String miniProgramPagePath;
	
	/**
	 * 跳转图文的媒体编号
	 */
	@NotEmpty(message = "跳转图文的媒体编号不能为空", groups = MpUtils.ViewLimitedButtonGroup.class)
	private String articleId;

	/**
	 * 消息类型
	 */
	@NotEmpty(message = "回复的消息类型不能为空", groups = {MpUtils.ClickButtonGroup.class, MpUtils.ScanCodeWaitMsgButtonGroup.class})
	private String replyMessageType;
	
	/**
	 * 回复的消息内容
	 */
	@NotEmpty(message = "回复的消息内容不能为空", groups = MpUtils.TextMessageGroup.class)
	private String replyContent;
	
	/**
	 * 回复的媒体文件 id
	 */
	@NotEmpty(message = "回复的消息 mediaId 不能为空",
			 groups = {
		MpUtils.ImageMessageGroup.class, MpUtils.VoiceMessageGroup.class, MpUtils.VideoMessageGroup.class})
	private String replyMediaId;
	
	/**
	 * 回复的媒体文件 URL
	 */
	@NotEmpty(message = "回复的消息 replyMediaUrl 不能为空",
			groups = {MpUtils.ImageMessageGroup.class, MpUtils.VoiceMessageGroup.class, MpUtils.VideoMessageGroup.class})
	private String replyMediaUrl;
	
	/**
	 * 回复的标题
	 */
	@NotEmpty(message = "回复的消息标题不能为空", groups = MpUtils.VideoMessageGroup.class)
	private String replyTitle;
	
	/**
	 * 回复的描述
	 */
	@NotEmpty(message = "消息描述不能为空", groups = MpUtils.VideoMessageGroup.class)
	private String replyDescription;
	
	/**
	 * 回复的缩略图的媒体 id
	 */
	@NotEmpty(message = "回复的消息 thumbMediaId 不能为空", groups = {MpUtils.MusicMessageGroup.class})
	private String replyThumbMediaId;
	
	/**
	 * 回复的缩略图的媒体 URL
	 */
	@NotEmpty(message = "回复的消息 thumbMedia 地址不能为空", groups = {MpUtils.MusicMessageGroup.class})
	private String replyThumbMediaUrl;

	/**
	 * 回复的图文消息数组
	 *
	 * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS
	 */
	@TableField(typeHandler = MpMessage.ArticleTypeHandler.class)
	private List<MpMessage.Article> replyArticles;
	
	/**
	 * 回复的音乐链接
	 */
	@NotEmpty(message = "回复的音乐链接不能为空", groups = MpUtils.MusicMessageGroup.class)
	private String replyMusicUrl;
	
	/**
	 * 回复的高质量音乐链接
	 */
	@NotEmpty(message = "回复的高质量音乐链接不能为空", groups = MpUtils.MusicMessageGroup.class)
	private String replyHqMusicUrl;

	/**
	 * 是否删除
	 */
	private Boolean deleted;

    public static LambdaQueryWrapper<MpMenu> lqw() {
		return Wrappers.lambdaQuery();
	}
}
